package com.neulogistics.core.substation.infrastructure.persistence.orm.po;

import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.util.Date;

import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.Data;

/**
 * 分站表
 * @TableName tb_substation
 */
@TableName(value ="tb_substation", autoResultMap = true)
@Data
public class SubstationPO implements Serializable {
    /**
     * 分站id
     */
    @TableId(value = "substation_id", type = IdType.AUTO)
    private Integer substationId;

    /**
     * 分站名
     */
    @TableField(value = "substation_name", condition = SqlCondition.LIKE)
    private String substationName;

    /**
     * 分站地址{省，市，区，详细，经纬度}
     */
    @TableField(value = "substation_address", typeHandler = JacksonTypeHandler.class)
    private JSONObject substationAddress;

    /**
     * 分站库房id
     */
    @TableField(value = "sub_warehouse_id")
    private Integer subWarehouseId;

    /**
     * 创建时间
     */
    @TableField(value = "create_time")
    private Date createTime;

    /**
     * 创建人id
     */
    @TableField(value = "creator_id")
    private Integer creatorId;

    /**
     * 是否删除
     */
    @TableField(value = "deleted")
    private Integer deleted;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        SubstationPO other = (SubstationPO) that;
        return (this.getSubstationId() == null ? other.getSubstationId() == null : this.getSubstationId().equals(other.getSubstationId()))
            && (this.getSubstationName() == null ? other.getSubstationName() == null : this.getSubstationName().equals(other.getSubstationName()))
            && (this.getSubstationAddress() == null ? other.getSubstationAddress() == null : this.getSubstationAddress().equals(other.getSubstationAddress()))
            && (this.getSubWarehouseId() == null ? other.getSubWarehouseId() == null : this.getSubWarehouseId().equals(other.getSubWarehouseId()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getCreatorId() == null ? other.getCreatorId() == null : this.getCreatorId().equals(other.getCreatorId()))
            && (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getSubstationId() == null) ? 0 : getSubstationId().hashCode());
        result = prime * result + ((getSubstationName() == null) ? 0 : getSubstationName().hashCode());
        result = prime * result + ((getSubstationAddress() == null) ? 0 : getSubstationAddress().hashCode());
        result = prime * result + ((getSubWarehouseId() == null) ? 0 : getSubWarehouseId().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getCreatorId() == null) ? 0 : getCreatorId().hashCode());
        result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", substationId=").append(substationId);
        sb.append(", substationName=").append(substationName);
        sb.append(", substationAddress=").append(substationAddress);
        sb.append(", subWarehouseId=").append(subWarehouseId);
        sb.append(", createTime=").append(createTime);
        sb.append(", creatorId=").append(creatorId);
        sb.append(", deleted=").append(deleted);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}